<!-- 最新专题 -->
<script setup>
import { reactive, ref } from 'vue'
import Panel from './home-panel.vue';
import More from '../more.vue';
import { NSkeleton, NSpace } from 'naive-ui'
import { findSpecial } from '../../api/home';
import { useLazyData } from '../../utils';


const homeSpecial = ref(null)
let special = useLazyData(homeSpecial, findSpecial)



</script>

<template>
  <div ref="homeSpecial">
    <Transition>
      <div style="margin: 30px 0px;" v-if="special.length <= 0">
        <n-space justify="center">
          <n-skeleton v-for="i in 3" height="288px" width="405px" />
        </n-space>
      </div>
      <Panel title="最新专题" v-else>
        <template v-slot:right>
          <More />
        </template>
        <div class="special-list" ref="homeSpecial">
          <div class="special-item" v-for="item in special" :key="item.id">
            <RouterLink to="/">
              <img alt v-lazy="item.cover" />
              <div class="meta">
                <p class="title">
                  <span class="top ellipse">{{ item.title }}</span>
                  <span class="sub ellipse">{{ item.summary }}</span>
                </p>
                <span class="price">&yen;{{ item.lowestPrice }}起</span>
              </div>
            </RouterLink>
            <div class="foot">
              <span class="like">
                <i class="iconfont icon-heart"></i>
                {{ item.collectNum }}
              </span>
              <span class="view">
                <i class="iconfont icon-eye"></i>
                {{ item.viewNum }}
              </span>
              <span class="reply">
                <i class="iconfont icon-message"></i>
                {{ item.replyNum }}
              </span>
            </div>
          </div>
        </div>
      </Panel>
    </Transition>
  </div>
</template>

<style scoped lang='less'>
.home-panel {
  background: #f5f5f5;
}
.special-list {
  height: 380px;
  padding-bottom: 20px;
  display: flex;
  justify-content: space-between;
  .special-item {
    width: 404px;
    background: #fff;
    .hoverShadow();
    a {
      display: block;
      width: 100%;
      height: 288px;
      position: relative;
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
      .meta {
        background-image: linear-gradient(
          to top,
          rgba(0, 0, 0, 0.8),
          transparent 50%
        );
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 288px;
        .title {
          position: absolute;
          bottom: 0px;
          left: 0;
          padding-left: 16px;
          width: 70%;
          height: 70px;
          .top {
            color: #fff;
            font-size: 17px;
            display: block;
          }
          .sub {
            display: block;
            font-size: 15px;
            color: #999;
          }
        }
        .price {
          position: absolute;
          bottom: 25px;
          right: 16px;
          line-height: 1;
          padding: 6px 10px;
          color: @priceColor;
          font-size: 16px;
          background-color: rgba(255, 255, 255, 0.952);
          border-radius: 2px;
        }
      }
    }
    .foot {
      height: 72px;
      line-height: 72px;
      padding: 0 20px;
      font-size: 15px;

      i {
        display: inline-block;
        width: 15px;
        height: 14px;
        font-size: 18px;
        margin-right: 5px;
        color: #999;
      }
      .like,
      .view {
        float: left;
        margin-right: 20px;
        vertical-align: middle;
      }
      .reply {
        float: right;
        vertical-align: middle;
      }
    }
  }
}
</style>